home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Internet Tools (InfoMagic)
/
Internet Tools.iso
/
news
/
moderating
/
submit.Z
/
submit
Wrap
Text File
|
1992-06-08
|
3KB
|
126 lines
: Use /bin/sh
# This script is used to submit articles to the NetNews system.
# (C) 1989 Dave Taylor, Intuitive Systems <taylor@sunworld.com>
#
# I usually invoke it while reading my email within my mailer,
# as "|submit groupname". -- Dave Taylor
inewscall="/usr/lib/news/inews -M -h"
approval="comp-sys-sun-announce@SunWorld.com"
activefile=/usr/lib/news/active
followup="comp.sys.sun.misc"
newsgroup=$1
# first off, are we called correctly?
if [ "$newsgroup" = "" ]
then
echo "Usage: $0 newgroup-name"
exit 1
fi
# now is this a valid newsgroup?
if [ ! -f $activefile ]
then
echo No active file\? Where\'s $activefile\?
exit 1
fi
pattern="^$newsgroup"
if [ "`egrep $pattern $activefile`" = "" ]
then
echo Can\'t find newsgroup $newsgroup in $activefile
exit 1
fi
# The next step is to create a temp file that contains the following
# headers and the message body:
#
# From: <the original line from the mail message>
# Subject: <the original subject>
# Distribution: world
# Organization: <the users org, if one exists>
# Approved: taylor@sunworld.com
# let's save the input stream...
cat - > /tmp/submit.$$
# note: we might have more than one, hence the "head -1" addition
from="`egrep '^From:' /tmp/submit.$$ | head -1`"
subject="`egrep '^Subject:' /tmp/submit.$$ | head -1`"
org="`egrep '^Organization:' /tmp/submit.$$ | head -1`"
if [ "$from" = "" ]
then
from="`head -1 /tmp/submit.$$ | awk -e '{ print \"From: \" $2 }'`"
if [ "$from" = "" ]
then
echo troubles getting a From: line.
from="From: anonymous"
fi
fi
# create the temp file...
echo "$from" > /tmp/inews.$$
if [ "$subject" = "" ]
then
echo "Subject: unknown" >> /tmp/inews.$$
else
echo "$subject" >> /tmp/inews.$$
fi
echo "Distribution: world" >> /tmp/inews.$$
if [ "$org" != "" ]
then
echo "$org" >> /tmp/inews.$$
else
echo "Organization: " >> /tmp/inews.$$
fi
echo "Approved: $approval" >> /tmp/inews.$$
echo "Followup-To: $followup" >> /tmp/inews.$$
# and now copy across the body of the message
cat /tmp/submit.$$ | \
awk -e '{ if (length($0) == 0) ok++; if (ok) print $0 }' \
>> /tmp/inews.$$
# let's let the user look at it and fix it up, perhaps
vi /tmp/inews.$$ < /dev/tty
# just check that this is what we want to do...
echo " "
/bin/echo -n "Are you sure you want to post this to $newsgroup ? "
read answer < /dev/tty
echo " "
if [ "$answer" = "no" -o "$answer" = "n" ]
then
echo posting cancelled.
/bin/rm -f /tmp/submit.$$ /tmp/inews.$$
exit 0
fi
echo executing the inews call
$inewscall -n $newsgroup < /tmp/inews.$$
/bin/rm -f /tmp/submit.$$ /tmp/inews.$$
echo .. posted without any problems\!
exit 0